package com.tw;

/**
 * Created by admin on 16/06/14.
 */
public class Seventh {
    public static void main(String[] args) {
        int n = 3;
        Seventh s = new Seventh();
        s.generateDiamondWithName(n, "Bill");
    }

    private void generateDiamondWithName(int n, String s) {
        this.generateIsoscelesTriangle(n - 1, 1);
        System.out.println(s);
        this.generateInvertedIsoscelesTriangle(n - 1, 1);
    }

    private void generateInvertedIsoscelesTriangle(int n, int verticalOffset) {
        int i, j;
        int RowStars = 1;
        for (i = 1; i < n; i++) {
            RowStars += 2;
        }
        for (i = 0; i < n; i++, RowStars -= 2) {
            for (j = 0; j < i + verticalOffset; j++) {
                System.out.print(" ");
            }
            for (j = 0; j < RowStars; j++) {
                System.out.printf("*");
            }
            System.out.println();
        }
    }

    private void generateIsoscelesTriangle(int n, int verticalOffset) {
        int i, j;
        int RowStars = 1;
        for (i = n; i > 0; i--, RowStars += 2) {
            for (j = 0; j < i - 1 + verticalOffset; j++) {
                System.out.printf(" ");
            }
            for (j = 0; j < RowStars; j++) {
                System.out.print("*");
            }
            System.out.printf("\n");
        }

    }
}